package cn.krund.lyc.hotlerobot.Ros.common.entity;

import java.util.ArrayList;
import java.util.List;

/**
 * @包名: cn.krund.lyc.hotlerobot.robot.common.entity
 * @作者: 刘育成
 * @时间: 2018/4/5  14:27
 * @org: 克路德人工智能
 * @描述: TODO  字节缓存类
 * @fileName: ByteCache
 */

public class ByteCache {

    private List<Byte> mList;
    public ByteCache(int maxSize){
        this.mList=new ArrayList<>();
    }
    public void add(byte[] datas){
        for (Byte b:datas){
            this.mList.add(b);
        }
    }

    public void clear(){
        this.mList.clear();
    }

    public byte get(int index){
        return this.mList.get(index);
    }

    public void remove(int index){
        this.mList.remove(index);
    }

    public int size(){
        return this.mList.size();
    }

    public byte[] toBytes(){
        byte[] ret = new byte[this.size()];
        for(int i=0;i<this.size();i++){
            ret[i]=this.mList.get(i);
        }
        return ret;
    }

}
